// ModelGenerator.h: interface for the ModelGenerator class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_MODELGENERATOR_H__BB8BBDAA_35EB_4391_BCE6_9EC6B68D0AED__INCLUDED_)
#define AFX_MODELGENERATOR_H__BB8BBDAA_35EB_4391_BCE6_9EC6B68D0AED__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <dbmain.h>
#include <afxtempl.h>
#include "AttachableVisitor.h"
#include "JointPart.h"
#include "DataSourceManager.h"
#include <fstream.h>

typedef AcDbEntity* (*GenerateEntity)( DataSourceManager* dsm );

class AFX_EXT_CLASS ModelGenerator : public JointSystem::AttachableVisitor
{
public:
	ModelGenerator( GenerateEntity ge ) { m_EntityGenerator = ge; }
	~ModelGenerator();

public:
	static ModelGenerator& Instance();

public:
	virtual void VisitJointPortOwner( JointSystem::JointPortOwner& );
	virtual void VisitPartChain( JointSystem::PartChain& );
	virtual void VisitJointPart( JointSystem::JointPart& );
	virtual void VisitJointPort( JointSystem::JointPort& );

public:
	void AutoSetup( const AcGeMatrix3d& shcs );
	AcDbEntity* GenerateEntityForPart( JointSystem::JointPart& part );
	AcDbEntity* GenerateEntityForPart( Part& part );

public:
	void Generate( JointSystem::PartChain& partChain );
	bool Generate( JointSystem::JointPart& part, JointSystem::PartChain& partChain );
	void Generate( JointSystem::JointPort& jp, JointSystem::PartChain& pc );

private:
	DataSourceManager* GenerateDSMForPart(const CString& DSItemID, Part& part);
	JointSystem::JointPart* GenerateJointPart(Part& part);
	DataSourceItem* GenerateDSItem(JointSystem::JointPart& part);

private:
	static GenerateEntity m_EntityGenerator;
	static HMODULE m_hEntityGenerator;
	
#if	defined(_ARXDEBUG) || defined(_DEBUG)
	fstream file;
#endif
};

#endif // !defined(AFX_MODELGENERATOR_H__BB8BBDAA_35EB_4391_BCE6_9EC6B68D0AED__INCLUDED_)
